package com.zaoniao.enstudy.infracore.web;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Getter;
import lombok.Setter;

/**
 * @author llb666
 * @date 2022/8/9 10:36
 */
@Getter
@Setter
@Tag( name = "通用响应体")
public class BaseResponse {

    public static final Integer SUCCESS_CODE = 200;
    protected static final String SUCCESS_MSG = "ok";

    @Schema(description = "响应业务状态", name = "status")
    protected Integer status;

    @Schema(description = "响应消息", name = "msg")
    protected String msg;

    public BaseResponse() {
        this(SUCCESS_CODE, SUCCESS_MSG);
    }

    @JsonCreator
    public BaseResponse(@JsonProperty("status") Integer status, @JsonProperty("msg") String msg) {
        this.status = status;
        this.msg = msg;
    }

    public static BaseResponse ok() {
        return new BaseResponse();
    }

    @Override
    public String toString() {
        return "BaseResponse{" +
                "status='" + status + '\'' +
                ", msg='" + msg + '\'' +
                '}';
    }
}
